#! /usr/bin/env bash
##########################################################################
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#
##########################################################################
#
# slurper.sh:  Copy files between local disk and HDFS.
#
# This script is customized to work nice with inittab respawn.
#
##########################################################################

# assume that we're already in the slurper home directory
BASEDIR=`pwd`

. $BASEDIR/conf/slurper-env.sh

if [ ! -f "${HADOOP_BIN}" ]; then
  echo "HADOOP_BIN must be set and point to the location of the hadoop script"
  exit 1;
fi

export SLURPER_JAR_DIR=$BASEDIR/lib

function add_to_classpath() {
  dir=$1
  for f in $dir/*.jar; do
    SLURPER_CLASSPATH=${SLURPER_CLASSPATH}:$f;
  done

  export SLURPER_CLASSPATH
}

add_to_classpath ${SLURPER_JAR_DIR}

export SLURPER_CONFIG_DIR="${BASEDIR}/config"

export HADOOP_CLASSPATH=${SLURPER_CONFIG_DIR}:${SLURPER_CLASSPATH}:${HADOOP_CLASSPATH}

export JAVA=$JAVA_HOME/bin/java
export JAVA_HEAP_MAX=-Xmx512m
